'\" te
.\" Copyright 1989 AT&T.  Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH SIGSEND 2 "Jul 19, 2004"
.SH NAME
sigsend, sigsendset \- send a signal to a process or a group of processes
.SH SYNOPSIS
.LP
.nf
#include <signal.h>

\fBint\fR \fBsigsend\fR(\fBidtype_t\fR \fIidtype\fR, \fBid_t\fR \fIid\fR, \fBint\fR \fIsig\fR);
.fi

.LP
.nf
\fBint\fR \fBsigsendset\fR(\fBprocset_t *\fR\fIpsp\fR, \fBint\fR \fIsig\fR);
.fi

.SH DESCRIPTION
.sp
.LP
The \fBsigsend()\fR function sends a signal to the process or group of
processes specified by \fIid\fR and \fIidtype\fR. The signal to be sent is
specified by \fIsig\fR and is either  0 or one of the values listed in
\fBsignal.h\fR(3HEAD). If \fIsig\fR is  0 (the null signal), error checking is
performed but no signal is actually sent.  This value can be used to check the
validity of \fIid\fR and  \fIidtype\fR.
.sp
.LP
The real or effective user \fBID\fR of the sending process must match the real
or saved user ID of the receiving process, unless the {\fBPRIV_PROC_OWNER\fR}
privilege is asserted in the effective set of the sending process or \fIsig\fR
is \fBSIGCONT\fR and the sending  process has the same session ID as the
receiving process.
.sp
.LP
If \fIidtype\fR is  \fBP_PID\fR, \fIsig\fR is sent to the process with process
\fBID\fR \fIid\fR.
.sp
.LP
If \fIidtype\fR is  \fBP_PGID\fR, \fIsig\fR is sent to all processes with
process group \fBID\fR \fIid\fR.
.sp
.LP
If \fIidtype\fR is  \fBP_SID\fR, \fIsig\fR is sent to all processes with
session \fBID\fR \fIid\fR.
.sp
.LP
If \fIidtype\fR is  \fBP_TASKID\fR, \fIsig\fR is sent to all processes with
task \fBID\fR \fIid\fR.
.sp
.LP
If \fIidtype\fR is  \fBP_UID\fR, \fIsig\fR is sent to any process with
effective user \fBID\fR \fIid\fR.
.sp
.LP
If \fIidtype\fR is  \fBP_GID\fR, \fIsig\fR is sent to any process with
effective group \fBID\fR \fIid\fR.
.sp
.LP
If \fIidtype\fR is  \fBP_PROJID\fR, \fIsig\fR is sent to any process with
project \fBID\fR \fIid\fR.
.sp
.LP
If \fIidtype\fR is  \fBP_CID\fR, \fIsig\fR is sent to any process with
scheduler class \fBID\fR \fIid\fR (see \fBpriocntl\fR(2)).
.sp
.LP
If \fIidtype\fR is  \fBP_CTID\fR, \fIsig\fR is sent to any process with process
contract ID \fIid\fR.
.sp
.LP
If \fIidtype\fR is  \fBP_ALL\fR, \fIsig\fR is sent to all processes and
\fIid\fR is ignored.
.sp
.LP
If \fIid\fR is  \fBP_MYID\fR, the value of \fIid\fR is taken from the calling
process.
.sp
.LP
The process with a process \fBID\fR of 0 is always excluded.  The process with
a process \fBID\fR of 1 is excluded unless \fIidtype\fR is equal to
\fBP_PID\fR.
.sp
.LP
The \fBsigsendset()\fR function provides an alternate interface for sending
signals to sets of processes. This function sends signals to the set of
processes specified by \fIpsp\fR. \fIpsp\fR is a pointer to a structure of type
\fBprocset_t\fR, defined in <\fBsys/procset.h\fR>, which includes the following
members:
.sp
.in +2
.nf
idop_t    p_op;
idtype_t  p_lidtype;
id_t      p_lid;
idtype_t  p_ridtype;
id_t      p_rid;
.fi
.in -2

.sp
.LP
The \fBp_lidtype\fR and \fBp_lid\fR members specify the \fBID\fR type and
\fBID\fR of one ("left") set of processes; the \fBp_ridtype\fR and \fBp_rid\fR
members specify the \fBID\fR type and \fBID\fR of a second ("right") set of
processes. \fBID\fR types and \fBID\fRs are specified just as for the
\fIidtype\fR and \fIid\fR arguments to \fBsigsend()\fR. The \fBp_op\fR member
specifies the operation to be performed on the two sets of processes to get the
set of processes the function is to apply to. The valid values for \fBp_op\fR
and the processes they specify are:
.sp
.ne 2
.na
\fB\fBPOP_DIFF\fR\fR
.ad
.RS 12n
Set difference: processes in left set and not in right set.
.RE

.sp
.ne 2
.na
\fB\fBPOP_AND\fR\fR
.ad
.RS 12n
Set intersection: processes in both left and right sets.
.RE

.sp
.ne 2
.na
\fB\fBPOP_OR\fR\fR
.ad
.RS 12n
Set union: processes in either left or right set or both.
.RE

.sp
.ne 2
.na
\fB\fBPOP_XOR\fR\fR
.ad
.RS 12n
Set exclusive-or: processes in left or right set but not in both.
.RE

.SH RETURN VALUES
.sp
.LP
Upon successful completion, \fB0\fR is return.  Otherwise, \fB\(mi1\fR is
returned and \fBerrno\fR is set to indicate the error.
.SH ERRORS
.sp
.LP
The \fBsigsend()\fR and \fBsigsendset()\fR functions will fail if:
.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
The \fIsig\fR argument is not a valid signal number, or the \fIidtype\fR
argument is not a valid idtype field.
.RE

.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
The \fIsig\fR argument is  \fBSIGKILL,\fR \fIidtype\fR is  \fBP_PID\fR and
\fIid\fR is  \fB1\fR (proc1).
.RE

.sp
.ne 2
.na
\fB\fBEPERM\fR\fR
.ad
.RS 10n
The effective user of the calling process does not match the real or saved user
ID of the receiving process, the calling process does not have the
{\fBPRIV_PROC_OWNER\fR} privilege asserted in the effective set, and the
calling process is not sending \fBSIGCONT\fR to a process that shares the same
session ID.
.sp
The calling process does not have the {\fBPRIV_PROC_SESSION\fR} privilege
asserted and is trying to send a signal to a process with a different session
ID, even though the effective user ID matches the real or saved ID of the
receiving process.
.RE

.sp
.ne 2
.na
\fB\fBESRCH\fR\fR
.ad
.RS 10n
No process can be found corresponding to that specified by \fIid\fR and
\fIidtype\fR.
.RE

.sp
.LP
The  \fBsigsendset()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBEFAULT\fR\fR
.ad
.RS 10n
The \fIpsp\fR argument points to an illegal address.
.RE

.SH SEE ALSO
.sp
.LP
.BR kill (1),
.BR getpid (2),
.BR kill (2),
.BR priocntl (2),
.BR signal (3C),
.BR signal.h (3HEAD),
.BR process (5),
.BR privileges (7)
